<admintpl file="header" />
</head>
<body>
<div class="wrap js-check-wrap">
    <ul class="nav nav-tabs">
        <li class="active"><a href="javascript:;">会员数统计</a></li>
    </ul>
    <form class="well form-search" method="post" id="form1">
        <label for="store_id">总店列表</label>
        <select name="store_id" id="store_id">
            <option value="">请选择总店</option>
            <foreach name="storeList" item="s">
                <option value="{$s.store_id}" <if condition="$store_id eq $s['store_id']">selected</if>>{$s.store_name}</option>
            </foreach>
        </select>
        <label for="store_parent_id">分店列表</label>
        <select name="store_parent_id" id="store_parent_id">
            <option value="">请选择分店</option>
            <foreach name="store_parentList" item="p">
                <option value="{$p.store_id}" <if condition="$store_parent_id eq $p['store_id']">selected</if>>{$p.store_name}</option>
            </foreach>
        </select>
        <br/><label for="test16">开始时间</label>
        <input type="text" class="js-datetime" name="start_time" id="test16"  placeholder="点击选择开始时间" style="width: 180px;"  value="{$start_time}">
        <label for="test17">结束时间</label>
        <input type="text" class="js-datetime" name="end_time" id="test17" placeholder="点击选择结束时间" style="width: 180px;"  value="{$end_time}">
        <input type="submit" class="btn btn-primary" value="搜索" onclick="return index()"/>
        <a class="btn btn-danger" href="{:U('Cencs/membership')}">清空</a>
        <input type="submit" class="btn btn-success" value="导出excel" onclick="return excel()"/>
        <div class="col-md-9" >
            <label>会员数据：</label>
            新增会员数:{$countMember|default=0}
            会员总数： {$totalMember|default=0}
            店铺总人数：{$totalMemberStore|default=0}
            店铺员工人数：{$totalMemberStaff|default=0}
        </div>
    </form>
    <if condition="$list neq ''">
        <table class="table table-hover table-bordered table-list">
            <thead>
            <tr>
                <th>ID</th>
                <th>会员名称</th>
                <th>会员手机号</th>
                <th>注册时间</th>
                <th>注册类型</th>
                <th>归属店铺</th>
                <th>推荐人</th>
            </tr>
            </thead>
            <tbody>
            <php>
                $referType = array("0"=>'普通注册',"1"=>'分享注册',"2"=>'心愿单分享注册');
            </php>
            <foreach name="list" item ="vo">
                <php>
                    $referInfo = M("member")->where(array('user_id'=>$vo['referid']))->find();
                </php>
                <tr>
                    <td>{$vo.user_id}</td>
                    <td>{$vo.user_name}|{$vo.real_name}</td>
                    <td>{$vo.phone_mob}</td>
                    <td>{$vo.reg_time|date="Y-m-d H:i:s",###}</td>
                    <td>{$referType[$vo['refer_type']]}</td>
                    <td>{$vo.store_name}</td>
                    <td>
                        <if condition="$referInfo['user_id'] eq ''">
                            无
                            <else/>
                            {$referInfo.user_name}|{$referInfo.real_name}
                        </if>
                    </td>
                </tr>
            </foreach>
            </tbody>
        </table>
    </if>
    <div class="pagination">{$page}</div>
</div>
<script src="__PUBLIC__/js/common.js"></script>
<script src="__PUBLIC__/layer/layer.js"></script>

<!-- iframe自适应高度 -->
</body>
<script type="text/javascript">

    function index(){
        $("#form1").attr('action',"{:U('Cencs/membership')}");
        return true;
    }
    function excel(){
        $("#form1").attr('action',"{:U('Cencs/excelMember')}");
        return true;
    }

    $("#store_id").change(function(){
        var store_id = $(this).val();
        var url = "{:U('Member/getStore')}";
        if(store_id != ''){
            var str = '<option value="">请选择分店</option>'
            $.post(url,{
                store_id:store_id
            },function(data){
                var res = JSON.parse(data);
                if(res.length > 0){
                    $.each(res,function(index,item){
                        str += "<option value='"+item.store_id+"'>"+item.store_name+"</option>";
                    })
                }
                $("#store_parent_id").html(str);
            })
        }
    })
</script>

</html>
